package wid;

import static org.junit.Assert.assertEquals;
import robocode.control.testing.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * This test simply verifies that Pacifist loses every round to Fire.
 * 
 * @author Philip Johnson
 * @author David Wilkie
 */
public class TestPacifistVersusFire extends RobotTestBed {

  /**
   * Specifies that SittingDuck and Pacifist are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Fire,wid.Pacifist";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * The actual test, which asserts that Pacifist has lost every round against Fire.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of getRobotNames.
    BattleResults[] battleResults = event.getIndexedResults();
    // Sanity check that results[1] is Pacifist (not strictly necessary, but illustrative).
    BattleResults pacifistResults = battleResults[1];
    String robotName = pacifistResults.getTeamLeaderName();
    assertEquals("Check that results[1] is Pacifist", robotName, "wid.Pacifist*");
    // Check to make sure Pacifist lost every round.
    assertEquals("Check Pacifist lost", pacifistResults.getSeconds(), getNumRounds());
  }
}
